package com.heima.comment.controller;

import com.heima.comment.service.CommentRepayService;
import com.heima.model.comment.dtos.CommentRepayDto;
import com.heima.model.comment.dtos.CommentRepayLikeDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Tangguo
 * @Date: 2023-06-28  15:20
 */
@RestController
@RequestMapping("/api/v1/comment_repay")
@Slf4j
public class CommentRepayController {

    @Autowired
    private CommentRepayService commentRepayService;

    /**
     * 保存评论回复
     * @param dto:
     * @return ResponseResult
     */
    @PostMapping("/save")
    public ResponseResult saveCommentRepay(@RequestBody CommentRepaySaveDto dto){
        log.info("保存评论回复:{}",dto);
        return commentRepayService.saveCommentRepay(dto);
    }


    /**
     * 查询评论回复列表
     * @param dto:
     * @return ResponseResult
     */
    @PostMapping("/load")
    public ResponseResult loadCommentRepay(@RequestBody CommentRepayDto dto){
        log.info("查询评论回复列表:{}",dto);
        return commentRepayService.loadCommentRepay(dto);

    }

    /**
     * 点赞
     * @param dto:
     * @return ResponseResult
     */
    @PostMapping("/like")
    public ResponseResult likeCommentRepay(@RequestBody CommentRepayLikeDto dto){
        log.info("点赞：{}",dto);
        return commentRepayService.likeCommentRepay(dto);

    }
}
